package com.yuyou.tas.report.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yuyou.tas.report.mapper.ExamModelWordRelMapper;
import com.yuyou.tas.report.service.IExamModelWordRelService;
import com.yuyou.tas.service.api.report.entity.ExamModelWordRel;
import com.yuyou.tas.util.bean.ResBoolSimpleInfo;
import com.yuyou.tas.util.tool.Sequence;

@Service
public class ExamModelWordRelServiceImpl implements IExamModelWordRelService{

	@Autowired
	private ExamModelWordRelMapper examModelWordRelMapper;
	
	@Override
	public int deleteByPrimaryKey(Long id) {
		return examModelWordRelMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(ExamModelWordRel record) {
		record.setId(Sequence.getSequence().nextId());
		record.setCreateTime(new Date());
		return examModelWordRelMapper.insert(record);
	}

	@Override
	public ExamModelWordRel selectByPrimaryKey(Long id) {
		return examModelWordRelMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(ExamModelWordRel record) {
		return examModelWordRelMapper.updateByPrimaryKeySelective(record);
	}

	@Transactional
	@Override
	public ResBoolSimpleInfo<String> setUp(ExamModelWordRel record) {		
		//删除
		examModelWordRelMapper.delByExamModelId(record.getExamModelId());
		if(record.getExamModelWordId()!=null){
			this.insert(record);
		}	
		return ResBoolSimpleInfo.getSuccessInfo();
	}

}